<template>
  <page-header-wrapper>

   
    <a-card :border="false">
      <div class="table-operator flex-y-center flex-x-sb">
      <!--  <div class="flex-y-center flex-x-sb">
          <a-radio-group v-model="queryParam.order_type" @change="statusChange">
            <a-radio-button :value="1"> 全部 </a-radio-button>
            <a-radio-button :value="2"> 激励视频 </a-radio-button>
            <a-radio-button :value="3"> 开屏广告 </a-radio-button>
            <a-radio-button :value="4"> 信息流广告 </a-radio-button>
          </a-radio-group>
        </div> -->
        <div>检索结果 {{ totalCount }} 条</div>
      </div>
      <a-table
        style="width: 100%; overflow-x: auto"
        v-if="columns.length"
        ref="tableList"
        :columns="columns"
        :data-source="dataSource"
        :loading="loading"
        :row-key="(record) => record.id"
        :pagination="{
          total: this.totalCount,
          current: this.pageNo,
          showSizeChanger: true,
          onChange: this.tablePageChange,
          onShowSizeChange: this.paginationSizeChange,
        }"
      >
<!--        <template slot="type" slot-scope="text, record">
          {{ record.type == 1 ? '收入' : record.type == 2 ? '支出' : '-' }}
        </template> -->
        <template slot="cycle_no" slot-scope="text, record">
          {{ record.cycle_no ? record.cycle_no : '-' }}
        </template>
        <template slot="rate" slot-scope="text, record"> {{ record.price }}/{{ record.rate }} </template>
        <template slot="order_type" slot-scope="text, record">
          {{
            record.order_type == 2
              ? '激励视频'
              : record.order_type == 3
              ? '开屏广告'
              : record.order_type == 4
              ? '信息流广告'
              : '-'
          }}
        </template>
        <template slot="order" slot-scope="text, record">
          {{ record.order ? record.order.order_no : '-' }}
        </template>
        <template slot="user" slot-scope="text, record">
          <span v-if="record.user"> {{ record.user.id }}/{{ record.user.nickname }}</span>
          <span v-else>-</span>
        </template>
  <!--      <template slot="status" slot-scope="text, record">
          {{ record.status == 0 ? '待结算' : record.status == 1 ? '已结算' : record.status == 2 ? '已退款' : '-' }}
        </template> -->
        <template slot="updated_at" slot-scope="text, record">
          {{ record.updated_at ? record.updated_at : '-' }}
        </template>
        <template slot="action" slot-scope="record">
          <a @click="edit(record)">编辑</a>
        </template>
        
      </a-table>
    </a-card>
    <editForm ref="editForm" @confirm="getList"></editForm>
  </page-header-wrapper>
</template>

<script>
import { poolList, poolStatistic, levelList } from '@/api/ad'
import editForm from './editForm'
export default {
  components: { editForm},
  name: 'pool-total-list-page',
  data() {
    return {
      columns: [
        {
          title: 'ID',
          dataIndex: 'id',
		      width: 120
        },
        {
          title: '等级',
          dataIndex: 'level.name',
          width: 120
        },
        
        {
          title: '一级比例',
          dataIndex: 'type',
          dataIndex: 'one_rate',
          width: 100
        },
        {
          title: '二级比例',
          dataIndex: 'two_rate',
          width: 100
        },
        {
          title: ' 团队比例',
          dataIndex: 'team_rate',
          width: 100
        },
        {
          title: ' 平级比例',
          dataIndex: 'same_rate',
          width: 100
        },
        {
          title: ' 平级几层',
          dataIndex: 'same_n',
          width: 100
        },
        {
          title: '操作',
          fixed: 'right',
          scopedSlots: { customRender: 'action' },
          width: 110,
        },
        // {
        //   title: '计算额/比例',
        //   dataIndex: 'rate',
        //   scopedSlots: { customRender: 'rate' },
        // },
        // {
        //   title: '查看',
        //   dataIndex: 'order_type',
        //   scopedSlots: { customRender: 'order_type' },
        //   width: 100
        // },
        // {
        //   title: '备注',
        //   dataIndex: 'desc',
        //   width: 180
        // },
        // {
        //   title: '订单信息',
        //   dataIndex: 'order',
        //   scopedSlots: { customRender: 'order' },
        // },
        // {
        //   title: '来源用户ID/昵称',
        //   dataIndex: 'user',
        //   scopedSlots: { customRender: 'user' },
        //   width: 150
        // },
        // {
        //   title: '状态',
        //   dataIndex: 'status',
        //   scopedSlots: { customRender: 'status' },
        //   width: 100
        // },
        // {
        //   title: '更新时间',
        //   dataIndex: 'updated_at',
        //   scopedSlots: { customRender: 'updated_at' },
        //   width: 180
        // },
      ],
      queryParam: {
        pool_id: 1,
        order_type: undefined,
        cycle_no: '',
        order_no: '',
        buy_uid: '',
        date_time: '',
        type: '',
        status: '',
      },
      loading: false,
      dataSource: [],
      totalCount: 0,
      total_money1: 0,
      total_money2: 0,
      pageNo: 1,
      pageSize: 10,

      poollist: [],
      statisticLst: [],
    }
  },
  created() {
    // this.getStatisticList() //总池统计
    // this.getPoolList() // 分池列表
    this.getList() //总池列表
  },
  methods: {
        // 编辑
     edit(item) {


      
      this.$refs.editForm.formData.id = item.id
      console.log(this.$refs.editForm.formData.id)
      this.$refs.editForm.getInfo()
    },
    // async getPoolList() {
    //   var newObj = {}
    //   newObj = { pageNo: 1, pageSize: 99999 }
    //   const res = await poolList(newObj)
    //   if (!res.code) {
    //     this.poollist = res.data.data
    //   }
    // },
    async getList() {
      var newObj = {}
      newObj = { ...this.queryParam, pageNo: this.pageNo, pageSize: this.pageSize }
      this.loading = true
      const res = await levelList(newObj)
      this.loading = false
      if (!res.code) {
        this.dataSource = res.data.data
        this.totalCount = res.data.totalCount
        this.total_money1 = res.data.total_money1
        this.total_money2 = res.data.total_money2
      }
    },
    // async getStatisticList() {
    //   const res = await poolStatistic()
    //   if (!res.code) {
    //     this.statisticLst = res.data
    //   }
    // },
    searchData() {
      this.pageNo = 1
      this.getList()
    },
    tablePageChange(e) {
      this.pageNo = e
      this.getList()
    },
    paginationSizeChange(current, size) {
      this.pageNo = current
      this.pageSize = size
      this.getList()
    },
    typechange(e) {
      this.queryParam.type = e.target.value
      this.getList()
    },
    statusChange(e) {
      this.queryParam.status = e.target.value
      this.getList()
    },
    dateChange(date, dateString) {
      this.queryParam.date_time = dateString[0] != '' ? `${dateString[0]}/${dateString[1]}` : ''
      // this.getList()
    },
  },
}
</script>

<style lang="less" scoped>
.permission-form {
  /deep/ .permission-group {
    margin-top: 0;
    margin-bottom: 0;
  }
}
.condition {
  min-width: 330px;
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
}
.pa10 {
  padding: 10px 5px;
  background-color: #fff;
  margin-bottom: 10px;
}
.pa101 {
  padding: 10px 20px;
  background-color: #fff;
  // margin-bottom: 10px;
}
.statistic {
  width: 12.5%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  font-size: 14px;
  color: #000;
  .money {
    font-size: 20px;
    font-weight: 600;
  }
}
</style>
